﻿using LiteBlog.Common.Entities;
using LiteBlog.Repositories.Common;
using LiteBlog.XmlLayer.Mocks.Constants;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using LiteBlog.Repositories;

namespace LiteBlog.Repositories.Tests
{
    [TestClass]
    public class ArchiveDataTests
    {
      
        private bool VerifyElement(XElement root, int filterMonth, int expectedCount)
        {
            var monthElem = root.Elements(Elem.Archive)
                .SingleOrDefault(elem =>
                    (int)elem.Attribute(Attr.Month) == filterMonth
                    && (int)elem.Attribute(Attr.Year) == ArchiveDataTestConstants.Year);
            if (monthElem != null)
            {
                int actualCount = (int)monthElem.Attribute(Attr.Count);
                return actualCount == expectedCount;
            }

            return false;
        }

        private bool VerifyNoElement(XElement root, int filterMonth)
        {
            var monthElem = root.Elements(Elem.Archive)
                .SingleOrDefault(elem => (int)elem.Attribute(Attr.Month) == filterMonth
                                      && (int)elem.Attribute(Attr.Year) == ArchiveDataTestConstants.Year);
            return monthElem == null;
        }
    }
}
